import { getPostByPublicSlugAndSlugForViewer } from "#server/service/posts"; export default defineEventHandler(async (event) => { const publicSlug = event.context.params?.publicSlug; const postSlug = event.context.params?.postSlug; if (!publicSlug || !postSlug || typeof publicSlug !== "string" || typeof postSlug !== "string") { throw createError({ statusCode: 400, statusMessage: "无效请求" }); } const viewer = await event.context.auth.getCurrent(); const post = await getPostByPublicSlugAndSlugForViewer(publicSlug, postSlug, viewer?.id ?? null); if (!post) { throw createError({ statusCode: 404, statusMessage: "未找到" }); } return R.success({ post }); });